<%#
    Auth: Wen
    Version: V1.0
    Data: 2019.8.20
    Function:
%>

<%+header%>
<html>
    <head>
    <meta charset="utf-8">
    <title>Wen</title>
    <script type="text/javascript">
    var XHR1 = new XHR();
	
    /* 定时刷新返回结果 */
    function GetSatelliteInfo()
    {
        //20s刷新一次
        //获取当前的卫星
        XHR1.post("<%=controller%>admin/ACU_Antenna/getSatelliteInfo", {token:'<%=token%>', step: '1'}, function(x)
        {
            //对返回的数据进行解析，并填入到相应的控件
            var str = x.responseText;
            //是否有错误警告
            if(str.match(/Error/g) == null)
            {
                var n = str.split(",");
                if(n[2] == '99.9')
                {
                    document.getElementById("satelliteLongitude").innerHTML = "HTS-A";
                }
                else
                {
                    document.getElementById("satelliteLongitude").innerHTML = n[2] + " &#176";
                }

                document.getElementById("trackingFrequency").innerHTML = n[3] + " MHz";
                if(n[4] == '0')
                {
                    document.getElementById("polMode").innerHTML = "<%:V%>";
                }
                else
                {
                    document.getElementById("polMode").innerHTML = "<%:H%>";
                }
                document.getElementById("dvbSymbolRate").innerHTML = n[5] + " ksym/s";
                document.getElementById("carrierBandwidth").innerHTML = n[6] + " KHz";
                if(n[7] == '0')
                {
                    document.getElementById("switch22K").innerHTML = "<%:OFF%>";
                }
                else
                {
                    document.getElementById("switch22K").innerHTML = "<%:ON%>";
                }
                switch(n[8])
                {
                    case '0':
                        document.getElementById("disq").innerHTML = "<%:OFF%>";
                        break;
                    case '1':
                        document.getElementById("disq").innerHTML = "1/4";
                        break;
                    case '2':
                        document.getElementById("disq").innerHTML = "2/4";
                        break;
                    case '3':
                        document.getElementById("disq").innerHTML = "3/4";
                        break;
                    case '4':
                        document.getElementById("disq").innerHTML = "4/4";
                        break;
                    case '5':
                        document.getElementById("disq").innerHTML = "1/8";
                        break;
                    case '6':
                        document.getElementById("disq").innerHTML = "3/8";
                        break;
                    case '7':
                        document.getElementById("disq").innerHTML = "5/8";
                        break;
                    case '8':
                        document.getElementById("disq").innerHTML = "8/8";
                        break;
                    default:
                        break;
                }
                if(n[9] == '0')
                {
                    document.getElementById("lnbVoltage").innerHTML = "13V";
                }
                else if(n[9] == '1')
                {
                    document.getElementById("lnbVoltage").innerHTML = "18V";
                }
                else if(n[9] == '2')
                {
                    document.getElementById("lnbVoltage").innerHTML = "<%:OFF%>";
                }             
                if(n[10] == '0')
                {
                    document.getElementById("trackingMode").innerHTML = "<%:DVB Mode%>";
                }
                else if(n[10] == '1')
                {
                    document.getElementById("trackingMode").innerHTML = "<%:Beacon Mode%>";
                }
                document.getElementById("loseTime").innerHTML = n[11] + " ms";
                var y = n[12].split("*");
                if(y[0] == '2')
                {
                    document.getElementById("multiaxisTracking").innerHTML = "<%:2-Axis%>";
                }
                else if(y[0] == '3')
				{
                    document.getElementById("multiaxisTracking").innerHTML = "<%:3-Axis%>";
                }
                document.getElementById("warmingGetSatInfo").innerHTML = "";
            }
            else
            {
                document.getElementById("warmingGetSatInfo").innerHTML = "Title:" + x.responseText;
            }
        });
    }
    function setSatelliteList()
    {
        var satLon;
        //检查参数是否正确
        if(document.getElementById("setSatelliteLongitude").value > 180 || document.getElementById("setSatelliteLongitude").value < -180)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Satellite longitude is error!%>";
        }
        else if(document.getElementById("setTrackingFrequency").value > 2150 || document.getElementById("setTrackingFrequency").value < 950)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Tracking frequency is error!%>";
        }
        else if(document.getElementById("setDvbSymbolRate").value < 0 || document.getElementById("setDvbSymbolRate").value > 99999)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:DVB symbol rate is error!%>";
        }
        else if(document.getElementById("setCarrierBandwidth").value < 0)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Carrier Bandwidth is error!%>";
        } 
        else if(document.getElementById("setLoseTime").value < 10)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Lost time is error!%>";
        }
        else if(document.getElementById("setLnbFrequency").value < 1000 ||document.getElementById("setLnbFrequency").value > 30000)
        {
            document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:LNB LO is error!%>";
        }
        else
        {
            //由于之后需要使用LUA解析，但‘-’是不可用的，所以需要进行替换
            if(document.getElementById("setSatelliteLongitude").value < 0)
            {
                satLon = 360 + parseFloat(document.getElementById("setSatelliteLongitude").value);
            }
            else
            {
                satLon = document.getElementById("setSatelliteLongitude").value;
            }

            var str1 = '{' + document.getElementById("setSatelliteNum").value + 
                ',' + document.getElementById("setEnable").value  + 
                ',' + document.getElementById("setSatelliteName").value  + 
                ',' + satLon + 
                ',' + document.getElementById("setTrackingFrequency").value  + 
                ',' + document.getElementById("setDvbSymbolRate").value  + 
                ',' + document.getElementById("setCarrierBandwidth").value + 
                ',' + document.getElementById("setLoseTime").value  + 
                ',' + document.getElementById("setLnbFrequency").value  + 
                ',' + document.getElementById("setPolarizationMode").value  + 
                ',' + document.getElementById("setSwitch22K").value  + 
                ',' + document.getElementById("setDisq").value  +
                ',' + document.getElementById("setLnbVoltage").value  + 
                ',' + document.getElementById("setTrackingMode").value  + 
                ',' + document.getElementById("setMultiaxisTracking").value + '}';	

            XHR1.post('<%=controller%>admin/ACU_Antenna/setSatelliteList', {token:'<%=token%>', para1:  document.getElementById("setSatelliteNum").value
            , str: str1}, function(x){
                
                //对返回的数据进行解析，并填入到相应的控件
                var str2 = x.responseText;

                //是否有错误警告
                if(str2.match(/Error/g) == null)
                {
                    document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Save satellite success!%>";
                }
                else
                {
                    document.getElementById("warmingSetSatInfo").innerHTML = "Title:" + x.responseText;
                }
            })            
        }
    }
    function getSatelliteList(value)
    {
        XHR1.post('<%=controller%>admin/ACU_Antenna/getSatelliteList', {token:'<%=token%>', para1: value}, function(x){

            //对返回的数据进行解析，并填入到相应的控件
            var str = x.responseText;
            //是否有错误警告
            if(str.match(/Error/g) == null)
            {
                var n = str.split(",");
                //document.getElementById("satelliteNum").value = n[0];
                document.getElementById("setEnable").value = n[1];
                document.getElementById("setSatelliteName").value = n[2];

                if(parseFloat(n[3]) > 180)
                {
                    document.getElementById("setSatelliteLongitude").value = '-' + (360 - parseFloat(n[3]));
                }
                else
                {
                    document.getElementById("setSatelliteLongitude").value = n[3];
                }

                document.getElementById("setTrackingFrequency").value = n[4];
                document.getElementById("setDvbSymbolRate").value = n[5];
                document.getElementById("setCarrierBandwidth").value = n[6];
                document.getElementById("setLoseTime").value = n[7];
                document.getElementById("setLnbFrequency").value = n[8];
                document.getElementById("setPolarizationMode").value = n[9];
                document.getElementById("setSwitch22K").value = n[10];
                document.getElementById("setDisq").value = n[11];   
                document.getElementById("setLnbVoltage").value = n[12];
                document.getElementById("setTrackingMode").value = n[13];
                var x = n[14].split("}")
                document.getElementById("setMultiaxisTracking").value = x[0];
                document.getElementById("warmingSetSatInfo").innerHTML = "";
            }
            else
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "Title:" + x.responseText;
            }
        })
    }
    function switchSatellite()
    {
		document.getElementById("warmingSetSatInfo").innerHTML = "";
		
        XHR1.post('<%=controller%>admin/ACU_Antenna/switchSatellite', {token:'<%=token%>', 
            para1:  document.getElementById("setSatelliteNum").value,
            para2:document.getElementById("setEnable").value,
            para3:document.getElementById("setSatelliteName").value,
            para4:document.getElementById("setSatelliteLongitude").value,
            para5:document.getElementById("setTrackingFrequency").value,
            para6:document.getElementById("setDvbSymbolRate").value,
            para7:document.getElementById("setCarrierBandwidth").value,
            para8:document.getElementById("setLoseTime").value,
            para9:document.getElementById("setLnbFrequency").value,
            para10:document.getElementById("setPolarizationMode").value,
            para11:document.getElementById("setSwitch22K").value,
            para12:document.getElementById("setDisq").value,
            para13:document.getElementById("setLnbVoltage").value,
            para14:document.getElementById("setTrackingMode").value,
            para15:document.getElementById("setMultiaxisTracking").value }, function(x){
			
            //对返回的数据进行解析，并填入到相应的控件
            var str2 = x.responseText;
            //是否有错误警告
            if(str2.match(/Error/g) == null)
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title:Switch satellite success!%>";
				GetSatelliteInfo();
            }
            else
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "Title:" + x.responseText;
            }
        })
    }
	
    function downloadList()
    {
        document.getElementById("warmingSetSatInfo").innerHTML = "";
		
        XHR1.post('<%=controller%>admin/ACU_Antenna/asySatellite', {token:'<%=token%>', para: "download"}, function(x){
			
            //对返回的数据进行解析，并填入到相应的控件
            var str2 = x.responseText;
            //是否有错误警告
            if(str2.match(/Error/g) == null)
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title: download list success!%>";
				GetSatelliteInfo();
            }
            else
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "Title:" + x.responseText;
            }
        })
    }
    function uploadList()
    {
        document.getElementById("warmingSetSatInfo").innerHTML = "";
        
        XHR1.post('<%=controller%>admin/ACU_Antenna/asySatellite', {token:'<%=token%>', para: "upload"}, function(x){
            
            //对返回的数据进行解析，并填入到相应的控件
            var str2 = x.responseText;
            //是否有错误警告
            if(str2.match(/Error/g) == null)
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "<%:Title: upload list success!%>";
                GetSatelliteInfo();
            }
            else
            {
                document.getElementById("warmingSetSatInfo").innerHTML = "Title:" + x.responseText;
            }
        })
    }
    GetSatelliteInfo();
    getSatelliteList(1);
    //document.getElementById("defaultOpen").click();
    </script>
    </head>
    <body>
        <p style="color:red;" id="warmingGetSatInfo"></p>
        <fieldset class="cbi-section">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Satellite Info%></h5>
            </div>
            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="33%"><%:Satellite Longitude%></td><td id="satelliteLongitude"></td></tr>
                    <tr><td width="33%"><%:Tracking Frequency%></td><td id="trackingFrequency"></td></tr>
                    <tr><td width="33%"><%:Pol Mode%></td><td id="polMode"></td></tr>
                    <tr><td width="33%"><%:DVB Symbol Rate%></td><td id="dvbSymbolRate"></td></tr>
                    <tr><td width="33%"><%:Carrier Bandwidth%></td><td id="carrierBandwidth"></td></tr>
                    <tr><td width="33%"><%:Switch 22K%></td><td id="switch22K"></td></tr>
                    <tr><td width="33%"><%:DISQ%></td><td id="disq"></td></tr>
                    <tr><td width="33%"><%:LNB Voltage%></td><td id="lnbVoltage"></td></tr>
                    <tr><td width="33%"><%:Tracking Mode%></td><td id="trackingMode"></td></tr>
                    <tr><td width="33%"><%:Lose Time%></td><td id="loseTime"></td></tr>
                    <tr><td width="33%"><%:Multi-axis Tracking%></td><td id="multiaxisTracking"></td></tr>
                </table>
            </div>
        </div>
        </fieldset>
        
        <p style="color:red;" id="warmingSetSatInfo"></p>
        <fieldset class="cbi-section">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Satellite List%></h5>
            </div>
            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="15%"><%:Satellite Number%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setSatelliteNum" size="1" onchange="getSatelliteList(this.value)">
                        <option value="1" selected="selected">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        </select></td></tr>
                    <tr><td width="15%"><%:ENABLE%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setEnable" size="1">
                        <option value="0" selected="selected"><%:DISABLED%></option>
                        <option value="1"><%:ENABLED%></option>
                        </select></td></tr>
                    <tr><td width="15%"><%:Satellite Name%></td><td><input id="setSatelliteName" type="text"  class="cbi-input-text"/>
                         <div class="cbi-value-description">
                            <%:Combination of letters and numbers%>
                        </div>
                        </td></tr>
                    <tr><td width="15%"><%:Satellite Longitude%></td><td><input id="setSatelliteLongitude" value="87.5" type="number" min="-180.0" max="180.0" step="0.1" class="cbi-input-number"/>
                        <div class="cbi-value-description">
                            <%:Range%>:-180.0~180.0 <%:more than 0 is the east longitude,otherwise it is the west longitude.%>
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Tracking Frequency%></td><td><input id="setTrackingFrequency" type="number" min="950.0000" max="2150.0000" step="0.0001" class="cbi-input-number"/>
                        <div class="cbi-value-description">
                            <%:Range%>:950.0000~2150.0000MHz. <%:L-Band Frequency.%>
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:DVB Symbol Rate%></td><td><input id="setDvbSymbolRate" type="number" min="2000" max="99999" step="1" class="cbi-input-number"/>
                        <div class="cbi-value-description">
                            <%:Range%>:2000~45000ksym/s
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Carrier Bandwidth%></td><td><input id="setCarrierBandwidth" type="number" min="0" max="30000" step="1" class="cbi-input-number"/>
                        <div class="cbi-value-description">
                            <%:Range%>:0~30000KHz
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Lose Time%></td><td><input id="setLoseTime" type="number" min="10" max="60000" step="1" class="cbi-input-number"/>
						<div class="cbi-value-description">
                            <%:Range%>:10~60000ms
						</div>
                    </td></tr>
                    <tr><td width="15%"><%:LNB Frequency%></td><td><input id="setLnbFrequency" type="number" min="1000" max="60000" step="1" class="cbi-input-number"/>
						<div class="cbi-value-description">
                            <%:Range%>:1000~30000MHz
						</div>
                    </td></tr>
                    <tr><td width="15%"><%:Pol Mode%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setPolarizationMode" size="1">
                        <option value="0"><%:V%></option>
                        <option value="1" selected="selected"><%:H%></option>
                        </select></td></tr>
                    <tr><td width="15%"><%:22K Switch%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setSwitch22K" size="1">
                        <option value="0" selected="selected"><%:OFF%></option>
                        <option value="1"><%:ON%></option>
                        </select></td></tr>
                    <tr><td width="15%"><%:DISQ%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setDisq" size="1">
                        <option value="0" selected="selected"><%:OFF%></option>
                        <option value="1">1/4</option>
                        <option value="2">2/4</option>
                        <option value="3">3/4</option>
                        <option value="4">4/4</option>
                        <option value="5">1/8</option>
                        <option value="6">3/8</option>
                        <option value="7">5/8</option>
                        <option value="8">8/8</option>
                        </select></td></tr>
                    <tr><td width="15%"><%:LNB Voltage%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setLnbVoltage" size="1">
                        <option value="0" selected="selected">13V</option>
                        <option value="1">18V</option>
                        <option value="2"><%:OFF%></option>
                        </select></td></tr>
                    <tr><td width="15%"><%:Tracking Mode%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setTrackingMode" size="1">
                        <option value="0" selected="selected"><%:DVB Mode%></option>
                        <option value="1"><%:Beacon Mode%></option>
                        <option value="2"><%:Narrow Mode%></option>
                        </select></td></tr>
                    <tr><td width="15%"><%:Multi-axis Tracking%></td><td>
                        <select class="cbi-input-select" data-update="change" id="setMultiaxisTracking" size="1">
                        <option value="2" selected="selected"><%:2-Axis%></option>
                        <option value="3"><%:3-Axis%></option>
                        </select></td></tr>
                </table>
            </div>
        </div>
        </fieldset>
        <div style="margin-top:15px;  margin-left:150px;">
            <input class="btn" style="width:100px; height:30px;" id="switch" type="button" value="<%:Switch Sat%>" onclick="switchSatellite()">
            <input class="btn" style="width:100px; height:30px;" id="save" type="button" value="<%:Save%>" onclick="setSatelliteList()">
            <input class="btn" style="width:100px; height:30px;" id="synToAcu" type="button" value="<%:Download List%>" onclick="downloadList()">
            <input class="btn" style="width:100px; height:30px;" id="synFromAcu" type="button" value="<%:Upload List%>" onclick="uploadList()">
        </div>
    </body>
</html>
<%+footer%>